package top.wineye.spring.dependency.lookup;


import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 通过 {@link ObjectProvider} 进行依赖查找
 */
public class ObjectProviderDemo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(ObjectProviderDemo.class);
        // lookup by ObjectProvider
        ObjectProvider<String> stringProvider = context.getBeanProvider(String.class);
        System.out.println(stringProvider.getObject());

        context.close();
    }


    @Bean
    public String helloWorld() {
        return "Hello World";
    }
}
